package com.heima.article.feign;

import com.heima.apis.article.IArticleFeign;
import com.heima.article.service.AuthorService;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojo.ApAuthor;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api("保存作者信息")
@RequestMapping("/api/v1/author")
public class AuthorFeign implements IArticleFeign {

    @Autowired
    AuthorService authorService;

    @ApiOperation("查询用户信息")
    @Override
    @GetMapping("/findByUserId/{userId}")
    public ApAuthor findByUserId(@PathVariable("userId") Integer userId) {
        return authorService.findByUserId(userId);
    }

    @ApiOperation("保存用户信息")
    @Override
    @PostMapping("/save")
    public ResponseResult insert(@RequestBody ApAuthor apAuthor) {
        return authorService.insert(apAuthor);
    }
}
